package com.shuyun.spi;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * @description:
 * @author: shuai.chen@shuyun.com
 * @date: 2021/8/16 1:47 下午
 */
public class SpiTest {

    public static void main(String[] args) {
        ServiceLoader<Animal> serviceLoader = ServiceLoader.load(Animal.class);
        Iterator<Animal> iterator = serviceLoader.iterator();
        while (iterator.hasNext()) {
            iterator.next().eat();
        }
    }

}
